<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!--    <meta charset="utf-8">-->
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <title>设置代金券</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="resources/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;" lay-filter="dataFrm" id="dataFrm">
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">代金券金额:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input perCouponNominal" name="perCouponNominal" lay-verify="required" >
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">失效时间:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input perCouponEndtime" name="perCouponEndtime" lay-verify="required" >
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <input type="hidden" id="serviceIdHiden"></input>
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="xg">修改</button>
        </div>
    </div>
    </div>
</form>
</body>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    var html = "";
    layui.use(['form', 'layer', 'table', 'laytpl', 'laydate', 'upload'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate,
            upload = layui.upload;


        form.on("submit(xg)", function (data) {
            var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.4});
            var perCouponNominal=$(".perCouponNominal").val();
            var perCouponEndtime=$(".perCouponEndtime").val();
            var perCouponId=$("#serviceIdHiden").val();
            $.post("/xgCoupon.do", {perCouponNominal:perCouponNominal,perCouponEndtime:perCouponEndtime,perCouponId:perCouponId}, function (res) {

                if (res.code == 200) {
                    setTimeout(function () {
                        top.layer.close(index);
                        top.layer.msg(res.msg);
                        parent.location.reload();
                    }, 2000)
                }
            }, "json");
            return false;
        });

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            var now = new Date();
            laydate.render({
                elem: '.perCouponEndtime',
                theme: 'molv',
                format:'yyyy-MM-dd HH:mm:ss',
                type: 'datetime',
                trigger: 'click',
                max:4073558400000, //公元3000年1月1日
                ready: function(date){
                    //console.log(date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                    this.dateTime.hours=now.getHours();
                    this.dateTime.minutes=now.getMinutes();
                    this.dateTime.seconds=now.getSeconds();
                }

            });
        });

    })
</script>
</body>
</html>